package com.bt.lms.ui.page.first;

import com.bt.lms.ui.page.sys.utils.MyHBox;
import javafx.collections.ObservableList;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;

/**
 * 设置密码界面
 */
public class PassSet extends VBox {

    /**
     * 界面所在容器
     */
    private final Pane pane;

    /**
     * 网格
     */
    private final GridPane gridPane;

    /**
     * 构建界面
     * @param pane 界面所在容器
     * @param gridPane 表格
     */
    public PassSet(Pane pane,GridPane gridPane) {

        this.pane = pane;
        this.gridPane = gridPane;

        //组件（修改密码网格）
        gridPaneInit(gridPane);
        ObservableList<Node> children = this.getChildren();
        children.add(gridPane);
    }

    /**
     * 修改密码网格初始化
     * @param gridPane 密码网格
     */
    private void gridPaneInit(GridPane gridPane) {


        //组件
        Label label = new Label("为保证账户安全，请先输入当前密码。");
        gridPane.add(label,1,8);


        Label presentLab = new Label("输入当前密码：");
        gridPane.add(presentLab,0,9);
        GridPane.setHalignment(presentLab, HPos.RIGHT);
        TextField presentTF = new TextField();
        gridPane.add(presentTF,1,9);

        Label newPassLab = new Label("输入新密码：");
        gridPane.add(newPassLab,0,10);
        GridPane.setHalignment(newPassLab, HPos.RIGHT);
        TextField newPassTF = new TextField();
        gridPane.add(newPassTF,1,10);
        Label passRuleLab = new Label("请输入新密码 ");
        gridPane.add(passRuleLab,2,10);
        Label passRuleTwoLab = new Label("密码长度6-14位，请尽量使用数字、字母组合，字母区分大小写");
        gridPane.add(passRuleTwoLab,3,10);

        Label notarizePassLab = new Label("确认新密码：");
        gridPane.add(notarizePassLab,0,11);
        GridPane.setHalignment(notarizePassLab, HPos.RIGHT);
        TextField notarizePassTF = new TextField();
        gridPane.add(notarizePassTF,1,11);
        GridPane.setHalignment(presentLab, HPos.RIGHT);

        //操作区
        MyHBox operateHBox = operateHBoxInit();
        gridPane.add(operateHBox,1,12);
    }

    /**
     * 操作区初始化
     * @return 操作区
     */
    private MyHBox operateHBoxInit() {

        MyHBox myHBox = new MyHBox();

        //布局
        Insets insets = new Insets(8);
        myHBox.setPadding(insets);
        myHBox.setSpacing(3);

        //组件
        Button saveBtn = new Button("保存修改");
        myHBox.getChildren().add(saveBtn);

        Button cancelBtn = new Button("取消");
        myHBox.getChildren().add(cancelBtn);

        return myHBox;
    }


}
